package com.sskj.ffex.p.activity;

import com.lzy.okgo.OkGo;
import com.lzy.okgo.model.Response;
import com.sskj.ffex.m.HttpConfig;
import com.sskj.ffex.m.bean.ExchangeHistoryEntry;
import com.sskj.ffex.m.bean.HttpData;
import com.sskj.ffex.m.http.JsonCallBack;
import com.sskj.ffex.p.base.BasePresenter;
import com.sskj.ffex.utils.ToastUtil;
import com.sskj.ffex.v.activity.ExchangeHistoryActivity;

public class ExchangeHistoryPresenter  extends BasePresenter<ExchangeHistoryActivity> {

    /**
     * 获取可兑换币种
     */
    public void getHistory(int page,int size) {
        OkGo.<HttpData<ExchangeHistoryEntry>>get(HttpConfig.BASE_URL + HttpConfig.EXCHANE_HISTORY)
                .params("p",page)
                .params("size",size)
                .execute(new JsonCallBack<HttpData<ExchangeHistoryEntry>>(this) {
                    @Override
                    protected void _onSuccess(Response<HttpData<ExchangeHistoryEntry>> response) {
                        if (response.body().status == 200) {
                            mView.setData(response.body().getData());
                        } else {
                            ToastUtil.showShort(response.body().getMsg());
                        }
                    }

                    @Override
                    public void onFinish() {
                        super.onFinish();
                        mView.stopRefresh();
                    }
                });
    }

}
